Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
exec-buffer
Advanced tools
The exec-buffer npm package is a utility for executing a buffer, typically used for processing images or other binary data. It provides a simple interface to run a binary and buffer the output, making it useful for tasks that involve manipulating binary data streams.
Execute a binary with input and output buffers
This feature allows you to execute a binary with input and output buffers. In this example, the input buffer is read from 'input.png', processed by the 'optipng' binary, and the output buffer is written to 'output.png'.
const execBuffer = require('exec-buffer');
const fs = require('fs');
const path = require('path');
const execa = require('execa');
(async () => {
const input = fs.readFileSync('input.png');
const output = await execBuffer({
input,
bin: 'optipng',
args: ['-out', execBuffer.output]
});
fs.writeFileSync('output.png', output);
})();
Execa is a modern alternative to child_process for executing external binaries. It provides a more user-friendly API and better defaults. Unlike exec-buffer, execa does not specifically focus on buffering binary data but is more general-purpose for executing commands.
The child_process module is a core Node.js module that provides the ability to spawn child processes. It is more low-level compared to exec-buffer and requires more boilerplate code to handle buffers and streams.
The buffer module is a core Node.js module that provides a way to handle binary data directly. While it does not execute binaries, it is often used in conjunction with other modules like child_process to manage binary data streams.
Run a Buffer through a child process
$ npm install --save exec-buffer
var ExecBuffer = require('exec-buffer');
var fs = require('fs');
var gifsicle = require('gifsicle').path;
var execBuffer = new ExecBuffer();
execBuffer.use(gifsicle, ['-o', execBuffer.dest(), execBuffer.src()]);
execBuffer.run(fs.readFileSync('test.gif'), function (err, data) {
if (err) {
throw err;
}
console.log(data);
//=> <Buffer 47 49 46 38 37 61 ...>
});
});
Creates a new ExecBuffer
instance.
Type: String
Path to the binary.
Type: Array
Arguments to run the binary with.
Type: String
Set or get the temporary source path.
Type: String
Set or get the temporary destination path.
Type: Buffer
The Buffer
to be ran through the child process.
Type: Function
Returns a Buffer
with the new data
and any stderr
output.
MIT © Kevin Mårtensson
FAQs
Run a buffer through a child process
The npm package exec-buffer receives a total of 339,455 weekly downloads. As such, exec-buffer popularity was classified as popular.
We found that exec-buffer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.